package com.chen.common;

import java.util.Locale;

/**
 * @Description
 * @Author Pengwei
 * @CreatDate 2021/11/14 14:53
 */
public class Utils {

    /**
     * 获取本地计算机语言
     */
    public static String getSysLanguage() {
        Locale locale = Locale.getDefault();
        return locale.getLanguage();
    }

    /**
     * 通过{}拼接字符串
     */
    public static String format(String format, Object... args) {
        if (args == null || args.length == 0) {
            return format;
        }
        for (Object arg : args) {
            if (arg == null) {
                arg = "";
            }
            format = format.replaceFirst("\\{\\}", arg.toString());
        }
        return format;
    }

    public static void main(String[] args) {
        String dsaf = format("{}大沙发{}沙发上{}", 1, "dsaf",null);
    }

}
